package com.spring.cloud.controller;

import com.spring.cloud.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConsumerController {



    @Autowired
    private HelloService helloService;

    @Value("${username}")
    private String  userName;

    @GetMapping("/getHello/{name}")
    public String getUserById(@PathVariable String name){
//        return this.restTemplate.ggetForObject(this.url+name, String.class);
        return helloService.hello(name);
    }

    @GetMapping("/getUserName")
    public String getUserName(){
        return userName;
    }

    @GetMapping("/error")
    public String error(){
        return "this is error";
    }

    @PostMapping("/error")
    public String psterror(){
        return "this is error";
    }
}
